package com.lie.prepare.multi_thread.queue;

/**
 * Created by lie on 2018/4/9.
 */
public class Butterer implements Runnable {

    private ToastQueue dryQueue, butteredQueue;

    public Butterer(ToastQueue dryQueue, ToastQueue butteredQueue) {
        this.dryQueue = dryQueue;
        this.butteredQueue = butteredQueue;
    }

    public void run() {
        try {
            while (!Thread.interrupted()) {
                //干面包上黄油
                Toast t = dryQueue.take();
                t.butter();
                System.out.println(t);
                //上了黄油的面包放进黄油队列
                butteredQueue.put(t);
            }
        }catch (InterruptedException e) {
            System.out.println("Butterer interrupt");
        }
        System.out.println("Butterer off");
    }
}
